/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package assignment_cp3120.view;

import java.awt.FlowLayout;
import java.awt.GridLayout;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JPanel;

/**
 * User Panel is the panel that gets added to the main frame to show the user view
 * @author Administrator
 */
public class UserPanel extends JPanel{
    private JButton deleteButton;
    private JPanel deletePanel;
    private JLabel deleteLabel;
    
    private JButton logoutButton;
    private JPanel logoutPanel;
    private JLabel logoutLabel;
    /**
     * Constructor, calls the create panel function
     */
    public UserPanel(){
        createPanel();
    }
    /**
     * Creates the panel and adds all the required buttons and labels
     */
    public void createPanel(){        
        GridLayout layout = new GridLayout(0,1);
        FlowLayout fl = new FlowLayout();
        
        deleteLabel = new JLabel("Delete this account");
        deletePanel = new JPanel(fl);
        deleteButton = new JButton("Delete");
        
        logoutLabel = new JLabel("Logout of this account");
        logoutPanel = new JPanel(fl);
        logoutButton = new JButton("Logout");
        
        deletePanel.add(deleteLabel);
        deletePanel.add(deleteButton);
        
        logoutPanel.add(logoutLabel);
        logoutPanel.add(logoutButton);
        
        add(deletePanel);
        add(logoutPanel);
        
        setLayout(layout);
    }
    /**
     * Sets the actions listener and actionCommand
     * @param a
     * Action listener to be added
     */
    public void buttonListener(ActionListener a){
        deleteButton.addActionListener(a);
        deleteButton.setActionCommand("delete");
    }

}
